{extend name="base" /} {block name="body"}
<div class="layui-body">
	<!--tab标签-->
	<div class="layui-tab layui-tab-brief">
		<ul class="layui-tab-title">
			<li class="">
				<a href="{:url('goods/index')}">商品管理</a>
			</li>
			<li class="layui-this">编辑商品</li>
		</ul>
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<form class="layui-form form-container" action="{:url('goods/update')}" method="post">
					<div class="layui-form-item">
						<label class="layui-form-label">商品编号</label>
						<div class="layui-input-block">
							<input type="text" name="goods_sn" value="{$goods.goods_sn}" required lay-verify="required" placeholder="请输入商品编号" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">商品名称</label>
						<div class="layui-input-block">
							<input type="text" name="goods_name" value="{$goods.goods_name}" required lay-verify="required" placeholder="请输入商品名称" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">商品分类</label>
					    <div class="layui-input-block">
					      <select name="goods_type" required lay-verify="required" lay-filter="aihao" class="layui-input">
					        <option value=""></option>
							{volist name="type_list" id="vo"}
							<option value="{$vo.id}" {if condition="$goods.goods_type==$vo.id" } selected="selected" {/if}>{$vo.name}</option>
							{/volist}
					      </select>
					    </div>
				  	</div>
					<div class="layui-form-item">
					<label class="layui-form-label">商品图片</label>
					<div class="layui-input-block" style="padding-left: 10px;">
						<div class="layui-upload">
							<button type="button" class="layui-btn" id="image">上传图片</button>
							<div class="layui-upload-list">
								<img class="layui-upload-img" src="{$goods.thumb}" style="width: 150px;height: 150px;" id="demo1">
								<p id="demoText"></p>
							</div>
						</div>
					</div>
					<input type="hidden" name="thumb" id="thumb" value="{$goods.thumb}"/>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">零售价</label>
						<div class="layui-input-block">
							<input type="text" name="sale_price" value="{$goods.sale_price}"  class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">会员价</label>
						<div class="layui-input-block">
							<input type="text" name="sale_price2" value="{$goods.sale_price2}"  class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">购买分佣</label>
						<div class="layui-input-block">
							<input type="text" name="buy_balance" value="{$goods.buy_balance}" value="0" lay-verify="required|number" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">一级会员分佣</label>
						<div class="layui-input-block">
							<input type="text" name="hy1_balance" value="{$goods.hy1_balance}" lay-verify="required|number" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">二级会员分佣</label>
						<div class="layui-input-block">
							<input type="text" name="hy2_balance" value="{$goods.hy2_balance}" lay-verify="required|number" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">合伙人分佣</label>
						<div class="layui-input-block">
							<input type="text" name="pt_balance" value="{$goods.pt_balance}" lay-verify="required|number" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">运营中心分佣</label>
						<div class="layui-input-block">
							<input type="text" name="city_balance" value="{$goods.city_balance}" lay-verify="required|number" class="layui-input">
						</div>
					</div>
				  	<div class="layui-form-item">
						<label class="layui-form-label">库存</label>
						<div class="layui-input-block">
							<input type="text" name="store" value="{$goods.store}" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">是否上架</label>
						<div class="layui-input-block">
							<input type="radio" name="is_on_sale" value="0" title="否" {if condition="$goods.is_on_sale==0" } checked="checked" {/if}>
							<input type="radio" name="is_on_sale" value="1" title="是" {if condition="$goods.is_on_sale==1" } checked="checked" {/if}>
						</div>
					</div>
					
					
					
					<div class="layui-form-item">
						<label class="layui-form-label">商品排序</label>
						<div class="layui-input-block">
							<input type="text" name="sort" value="{$goods.sort}" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item" >
						<label class="layui-form-label">商品介绍</label>
						<div class="layui-input-block" style="z-index: 1">
							<script style="width:960px;height:600px;" id="content" name="content" type="text/plain">
								{if isset($goods.content)}{$goods.content|html_entity_decode}{/if}
							</script>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<input type="hidden" name="id" value="{$goods.id}">
							<button class="layui-btn" lay-submit lay-filter="*">更新</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="js"}
<script type="text/javascript" src="/public/static/js/image.zip.js"></script>
<script type="text/javascript" src="/public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/public/ueditor/ueditor.all.js"></script>

<script>
	var ue = UE.getEditor('content', {
        initialFrameHeight: 450,
		serverUrl: "{:url('admin/ueditor/index?cate=news')}"
	});
	var GV = {
		current_controller: "goods/index"
	};
	layui.use('upload', function() {
		var upload = layui.upload,
		jq = layui.jquery;
		upload.render({
			url: '{:url("upload")}',
			elem: '#image',
			ext: 'jpg|png|gif',
			area: ['500', '500px'],
			before: function(input) {
				
			},
			done: function(res) {
				if(res.code==1){
					$("#demo1").attr('src',res.src);
					$("#thumb").val(res.src);
				}
			}
		});
	})
</script>
{/block}